
#include<avr/io.h>
#include<avr/interrupt.h>
#include "Init.h"

void Init_all(void)
{

UART_Init();


}






////UART_Init function   expects clock to be 8 MHz
////////////////////////////////////////////////////
void UART_Init(void)
{

	//Set baud rate
        UBRR1H = 0; //high byte
	UBRR1L = 95;		//low byte



	UBRR0H = 0; //high byte
	UBRR0L = 95;
	//Set data frame format: asynchronous mode,no parity, 1 stop bit, 8 bit size

	UCSR0C=(0<<UMSEL01)|(0<<UMSEL00)|(0<<UPM01)|(0<<UPM00)|

		(0<<USBS0)|(0<<UCSZ02)|(1<<UCSZ01)|(1<<UCSZ00);	

	UCSR1C=(0<<UMSEL11)|(0<<UMSEL10)|(0<<UPM11)|(0<<UPM10)|

		(0<<USBS1)|(0<<UCSZ12)|(1<<UCSZ11)|(1<<UCSZ10);		

	//Enable Transmitter and Receiver and Interrupt on transmit complete

	UCSR0B=(1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0);
	UCSR1B=(1<<RXEN1)|(1<<TXEN1);//|(1<<RXCIE1);

	//enable global interrupts, done that in main




}
